package com.stone.boot.stoneboot;

import com.stone.boot.stoneboot.runner.MyApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@SpringBootApplication
public class StoneBootApplication {

    public static void main(String[] args) {
        SpringApplication.run(StoneBootApplication.class, args);
    }

    /**
     * 创建并配置一个CommandLineRunner bean
     * 该bean将在应用启动后执行指定的操作
     * 主要用于执行应用启动时需要完成的异步任务或初始化任务
     *
     * @param env Environment对象，包含应用运行时的环境信息，如配置属性
     * @return 返回一个MyApplicationRunner实例，用于执行应用启动后的特定逻辑
     */
    @Bean
    public CommandLineRunner commandLineRunner(Environment env){
        return new MyApplicationRunner(env);
    }

}
